/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package models.beans;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Hoang Dong Tien
 */
public class Event extends org.apache.struts.action.ActionForm {

    private int eventId;
    private String eventName;
    private String eventType;
    private Date startDate;
    private Date endDate;
    private String description;
    private String eventImage;
    private int createUserId;
    public static final String TYPE_MEETING = "meeting";
    public static final String TYPE_SEMINAR = "seminar";
    public static final String TYPE_COMPETITION = "competition";

    public Event() {
        super();
        this.eventId = 0;
        this.eventName = "";
        this.eventType = Event.TYPE_MEETING;
        this.startDate = new Date();
        this.endDate = new Date();
        this.description = "";
        this.eventImage = "";
        this.createUserId = 0;
    }

    public String getEventImage() {
        return eventImage;
    }

    public void setEventImage(String EventImage) {
        this.eventImage = EventImage;
    }

    public int getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(int createUserId) {
        this.createUserId = createUserId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getEndDate() {
        return endDate;
    }



    public void setEndDate_sql(Date endDate) {
        this.endDate = endDate;
    }

    public void setEndDate(String endDate) throws ParseException {
        Date date = SimpleDateFormat.getInstance().parse(endDate);
        this.startDate = date;
    }

    public int getEventId() {
        return eventId;
    }

    public void setEventId(int eventId) {
        this.eventId = eventId;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    public String getEventType() {
        return eventType.toLowerCase();
    }

    public void setEventType(String eventType) {
        if (eventType.equalsIgnoreCase(Event.TYPE_COMPETITION)
                || eventType.equalsIgnoreCase(Event.TYPE_SEMINAR)
                || eventType.equalsIgnoreCase(Event.TYPE_MEETING)) {
            this.eventType = eventType.toLowerCase();
        }
    }

    public Date getStartDate() {
        return startDate;
    }

   

    public void setStartDate_sql(Date startDate) {
        this.startDate = startDate;
    }

    public void setStartDate(String datestr) throws ParseException {
        Date date = SimpleDateFormat.getInstance().parse(datestr);
        this.startDate = date;
    }

    public java.sql.Date getStartDate_sql() {
        return new java.sql.Date(this.startDate.getTime());
    }

    public java.sql.Date getEndDate_sql() {
        return new java.sql.Date(this.endDate.getTime());
    }

    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();

        return errors;
    }
}
